package database;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.Properties;

public class DatabaseConnector {
	public DatabaseConnector() throws ClassNotFoundException,IllegalAccessException,InstantiationException{
		url = DatabaseConfig.URL;
		driver = DatabaseConfig.DRIVER;
		prop = DatabaseConfig.getProp();
		Class.forName(driver).newInstance(); 
	}
	protected void connectDB() throws SQLException{
		connection= DriverManager.getConnection(url, prop);
		statement = connection.createStatement();
	}
	protected void closeDB() throws SQLException{
		if(connection != null) {
			connection.close();
		    connection = null;
		}
	}
	protected Connection connection;
	protected Statement statement;
	protected PreparedStatement preparedStatement;
	protected String url;
	protected String driver;
	protected Properties prop;
}
